package com.qys.livesMall.product.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Map;

/**
 * <p>
 * H2ShopSku对象
 * </p>
 *
 * @author gmx
 * @since 2023-05-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("h2_product_sku")
public class H2ProductSku implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id",type = IdType.ASSIGN_ID)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;
    /**
     * sku名字,属性逗号组成
     */
    @TableField("name")
    private String name;
    /**
     * 价格,不能为空
     */
    @TableField("price")
    @NotNull(message = "价格不能为空")
    private BigDecimal price;
    /**
     * 库存,不能为空
     */
    @TableField("num")
    @NotNull(message ="库存不能为空")
    @Min(value = 0,message = "库存不能小于0")
    private Integer num;
    /**
     * 图片
     */
    @TableField("image")
    private String image;
    /**
     * 图片列表
     */
    @TableField("images")
    private String images;
    /**
     * 商品id
     */
    @TableField("spu_id")
    private Long spuId;
    /**
     * 二级类目ID
     */
    @TableField("category_id")
    private Long categoryId;
    /**
     * 类目名称
     */
    @TableField("category_name")
    private String categoryName;
    /**
     * 品牌id
     */
    @TableField("brand_id")
    private Long brandId;
    /**
     * 品牌名称
     */
    @TableField("brand_name")
    private String brandName;
    /**
     * 规格,不能为空
     */
//    @TableField(value = "sku_attribute",typeHandler = JacksonTypeHandler.class)
//    @NotNull(message = "规格不能为空")
//    private Map<String,Object> skuAttribute;
    @TableField(value = "sku_attribute")
    @NotNull(message = "规格不能为空")
    private String skuAttribute;
    /**
     * 商品状态 1-正常，2-下架，3-删除
     */
    @TableField("status")
    private Integer status;
    /**
     * 创建时间
     */
    @JsonIgnore
    @TableField("create_time")
    private LocalDateTime createTime;
    /**
     * 更新时间
     */
    @JsonIgnore
    @TableField("update_time")
    private LocalDateTime updateTime;
    /**
     * 创建人
     */
    @TableField("create_by")
    private String createBy;
    /**
     * 更新人
     */
    @TableField("update_by")
    private String updateBy;

}
